﻿using AppServices.User.Dto;
using AutoMapper;
using Domain;
using Domain.Entities;
using Infrastructure.Bases;
using Infrastructure.Options;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;


namespace AppServices.Test
{
    public class TestAppService
    {
        private readonly BaseRepository<UserInfo> _userRepository;
        private readonly BaseRepository<Role> _roleRepository;
        private readonly IMapper _mapper;
        private readonly JwtTokenOption _jwtOption;

        public TestAppService(BaseRepository<UserInfo> userRepository, BaseRepository<Role> roleRepository, IMapper mapper, IOptionsMonitor<JwtTokenOption> jwtOption)
        {
            _userRepository = userRepository;
            _roleRepository = roleRepository;
            _mapper = mapper;
            _jwtOption = jwtOption.CurrentValue;
        }

        /// <summary>
        /// 测试用例
        /// </summary>
        /// <param name="loginDto"></param>
        /// <returns></returns>
        public string Test()
        {
            bool isSame= _userRepository._db.GetHashCode()==_roleRepository._db.GetHashCode();
            string msg = "是否是同一个sqlsugarclient:" + isSame;
            Console.WriteLine(msg);
            return msg;
        }


        ///// <summary>
        ///// 登陆用例
        ///// </summary>
        ///// <param name="loginDto"></param>
        ///// <returns></returns>
        //public async Task<bool> Login(LoginReq loginReq)
        //{
        //    bool isHas = await _baseRepository.Query(p => p.UserName.Equals(loginReq.NickName) && p.Pwd.Equals(loginReq.Password));
        //    return isHas;
        //}

    }
}
